<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!DOCTYPE HTML>
<html>
<head>
    <base href="${ctx }/">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <link rel="stylesheet" href="plugin/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/bootstrap-datetimepicker.css"/>
    <link rel="stylesheet" href="plugin/bootstrap-table/dist/bootstrap-table.css">
    <!-- <link rel="stylesheet" href="css/zoom.css" media="all" />  -->
    <link rel="stylesheet" href="alert/alert.css">
     <style type="text/css">
         .addbr{
     float: right;
    margin-right: 80px;
  }
  .pad{
    padding-left:15px;
    padding-top:10px;
  }
  .im{
     padding:10px;
  }
  .padtr{
      margin-top:5px;
  }
  #filediv1{
  border: 2px solid #ccc6c6;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    display: inline-block;
    margin-right: 20px;
  }
        a{
        color: #73879C;
        }
    </style>
</head>
<body>

        <div>
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home home-icon"></i>
                    <a href="javascript:void(0)">Rider Management(乘客管理)</a>
                </li>
                <li class="active">
                    <a href="view/appUser/user_list.jsp">Rider Database(乘车列表)</a>
                </li>
            </ul>
        </div>
            <div class="form-inline" role="form" method="post" id="queryForm">
                <div class="form-group">
                    <label>Registration time(注册时间):</label>
                    <input type="text" class="form-control input-append form_date" id="startTime">-
                    <input type="text" class="form-control input-append form_date" id="endTime">
                </div>
                <div class="form-group">
                    <label>Mobile(手机号):</label>
                    <input type="text" id="telephone" placeholder="phone number" class="form-control">
                </div>
                <div class="form-group">
                    <label>Account status（账号状态）:</label>
                    <select id='isOnline' class="form-control">
                        <option value="">all</option>
                        <option value="1">online</option>
                        <option value="2">offline</option>
                    </select>
                </div>
                   <div class="form-group">
                    <label>User status(用户状态):</label>
                    <select id='isDeleted' class="form-control">
                        <option value="">all</option>
                        <option value="0">enable</option>
                        <option value="1">disable</option>
                    </select>
                </div>
                    <div class="form-group">
                    <label>Gender(性别):</label>
                    <select id='sex' class="form-control">
                        <option value="">Total</option>
                        <option value="0">Male</option>
                        <option value="1">Demale</option>
                        <option value="2">Other</option>
                    </select>
                </div>
                <input type='hidden' id="sortName" />
                 <div class="form-group">
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button id="queryBtn" onclick="doQuery1('demo-table',queryParams1())" class="btn btn-primary">Search(搜索)
                </button>
                <button id="queryBtn" onclick="exportTable()" class="btn btn-primary">Export(导出)
                </button>
                 <button id="queryBtn" onclick="addUser()" class="btn btn-primary">Add(添加)
                </button>
                </div>	
                
            </div>
        <br>
        <p id="onLineNum" style='text-align: center;color: red;'></p>
    <table id="demo-table"></table>
   
</body>

<!-- 加载需要的js -->
<script src="js/jquery-3.2.1.min.js"></script>
<script src="plugin/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="js/jquery-bootstrap-pagination.js"></script>
<script src="plugin/bootstrap-table/dist/bootstrap-table.min.js"></script>
<script src="plugin/bootstrap-table/dist/locale/bootstrap-table-zh-CN.min.js"></script>
<script src='alert/alert.js'></script>
<!--时间  -->
<script src="js/bootstrap-datetimepicker.js"></script>
<script src="js/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="js/common.js"></script>
<script src="plugin/layer/layer.js"></script>
<script type="text/javascript" charset="utf-8">
    var M = {}

    $('.form_date').datetimepicker({
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        language: 'zh-CN',
        format: 'dd/mm/yyyy',
        todayBtn: 1,
        autoclose: 1,
    });

    $(function () {
        initPath("${ctx }");
        initCity();
       onLineNum();//在线人数
        inittable1('demo-table', queryParams, columns, "user/getList");
        
    });
    function onLineNum(){
    	 $.getJSON({
             url: "user/getOnLineNum",
             data: {},
             success: function (data) {
                 if (data.code == 200) {
                     $('#onLineNum').html("<span style='color: red;'>The number of online："+data.data+"</span>");
                 } 
             }
         });
    }
    //点击div时点击file
	function fileSize(file,num){
		 var image = new Image();
		 var _URL = window.URL || window.webkitURL;
		 var width =0; var height = 0;
	      image.onload =function(){  
	         width = image.width;  
	         height = image.height;
	         $('#filedivs'+num+'').css("display","none");
		      $('#imgs'+num+'').css("display","block");
		      $('#imgs'+num+'').attr("src",image.src);
	      }  
	    	  image.src =  _URL.createObjectURL(file.files[0]);
			    var reader = new FileReader();  
			    //将文件以Data URL形式读入页面  
			    reader.readAsDataURL(file.files[0]);  
			    reader.onload=function(e){  
			    	var r = "result"+num+"";
			        var result=document.getElementById(r);  
			        //显示文件  
			        result.value=this.result;  
	      }
	}
    //添加用户
    function addUser(){
    	layer.open({
			  type: 1,
			  title: "Add User",
			  skin: 'layui-layer-rim', //加上边框
			  area: ['620px', '660px'], //宽高
			  content: ' <form id="adds" id="adds"><table>'+
			  '  <tr class="padtr"><td class="pad">Upload the picture(上传头像):</td> '+
			 ' <td style="padding: 10px 20px;"><div id="filedivs1" ><label for="file1" ><div id="filediv1" ><span class="glyphicon glyphicon-plus im"></span></div>'+
	        '<input type="file" id="file1"  onchange="fileSize(this,1)" accept="image/jpeg,image/jpg,image/png" style="display:none"/>  </label></div>'+
	        '<input type="hidden" id="result1" /><img src="" style="width:50px;height:50px;display:none" onclick="javascript:$(\'#file1\').click()" id="imgs1"/>'+
	        '</td></tr>'+     	 		      
          '<tr><td><span style="font-size:20px">&nbsp;Rider Information(用户信息)：</span></td></tr>'+
			  '  <tr class="padtr"><td class="pad">Name(名称):</td> '+
       '<td><input type="text"  style="width:80px" name="firstName" id="firstName">&nbsp;<input type="text" style="width:80px" id="middleName" name="middleName">&nbsp;<input type="text" style="width:80px" id="name" name="name"></td></tr>'+
   /*    '  <tr class="padtr"><td class="pad">Gender(性别):</td> '+
      '<td><select class="form-control" name="sex" id="sex"><option value="0">male<option><option value="1">female<option><option value="2">Other<option></select></td></tr>'+ */
      '  <tr class="padtr"><td class="pad">Phone(电话):</td> '+
       '<td><input type="text" class="form-control"   name="telephone" id="telephone1" oninput="regTel(\'telephone1\')" /></td></tr>'+
       '  <tr class="padtr"><td class="pad">Password(密码):</td> '+
       '<td><input type="password" class="form-control" name="password" id="password" oninput="regPassword(\'password\')" /></td></tr>'+
      '  <tr class="padtr"><td class="pad">Email(邮箱):</td> '+
      '<td><input type="text" class="form-control" name="email" id="email" oninput="regEmail(\'email\')" /></td></tr>'+
   /*    '  <tr class="padtr"><td class="pad">Postcode(邮编):</td> '+
      '<td><span>0111025645</span></td></tr>'+ */
       '<tr><td><span style="font-size:20px">&nbsp;Coupons(优惠劵信息)：</span></td></tr>'+
       '<tr class="padtr"><td class="pad">Coupon Name(优惠劵名称):</td> '+
       '<td><input type="text"  id="couponName"/>' 
       +'<input type="hidden" id="type" value="1"/><input type="hidden" id="giftedPeopleName" value="${user.name}"/></td></tr>'+
       
       '  <tr class="padtr"><td class="pad">Coupon amount(优惠劵金额):</td> '+
       '<td><input type="number" id="couponMoney"  oninput="regca(\'couponMoney\')"/></td></tr>'+
       '  <tr class="padtr"><td class="pad">Describe(描述):</td> '+
       '<td><input type="text"  id="remark"/></td></tr>'+
      '<tr align="center" class="padtr" ><td colspan="5" style="padding-top:10px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
       ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
       ' <button type="button" onclick="cacel()" class="btn btn-info btn1">&nbsp;&nbsp;Cancel&nbsp;&nbsp;</button>'+
       '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
       '<button type="button" onclick="save()" class="btn btn-info btn1">&nbsp;&nbsp;Save&nbsp;&nbsp;</button></td></tr></table></form>'
			});
	   $('.form_date').datetimepicker({
	        minView: "month", //选择日期后，不会再跳转去选择时分秒 
	        language: 'zh-CN',
	        format: 'dd/mm/yyyy',
	        todayBtn:  1,
	        autoclose: 1,
	    });
    }
    //验证密码长度 6-18字段
    function regPassword(id){
    	var text=$('#'+id+'').val();
    	if(text.length<6||text.length>18){
			 $('#'+id+'').css("border-color","#FF0000")
		 }else{
			$('#'+id+'').css("border-color","#ccc")
		 }
    }
    function regEmail(id){
    	//var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
    	var myreg =/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
    	var text=$('#'+id+'').val();
    	if(!myreg.test(text)){
    		 $('#'+id+'').css("border-color","#FF0000")
    	}else{
    		$('#'+id+'').css("border-color","#ccc")
    	}
    }
    function regTel(id){
    	var text=$('#'+id+'').val();
    	if(text.length>10||text.length<8){
    		 $('#'+id+'').css("border-color","#FF0000")
    	}else{
    		$('#'+id+'').css("border-color","#ccc")
    	}
    }
    function save(){
    	 var forms= serialize('adds');
    	 if(forms.firstName==null||forms.firstName==""){
     		layer.msg("firstName cannot be empty");
     		return;
     	}
    	 if(forms.password==null||forms.password==""){
      		layer.msg("Password cannot be empty");
      		return;
      	}
    	 if(forms.telephone==null||forms.telephone==""){
       		layer.msg("Telephone cannot be empty");
       		return;
       	}
    	 var telephone=forms.telephone;
    	 	forms.telephone =telephone.substring(telephone.length-8, telephone.length); 
    	 if(forms.email==null||forms.email==""){
        		layer.msg("Email cannot be empty");
        		return;
        	}
    	var result1=$('#result1').val();
    	 forms.picture =result1;
    	 var couponName=$('#couponName').val();
    	 var type=$('#type').val();
    	 var giftedPeopleName=$('#giftedPeopleName').val();
    	 var couponMoney=$('#couponMoney').val();
    	 if(couponName==""){
    		 layer.msg("Coupon Name cannot be empty");
    		 return ;
    	 }
    	 if(couponMoney==""){
    		 layer.msg("Coupon Money cannot be empty");
    		 return ;
    	 }
    	 var uc={"couponName":couponName,"type":type,"giftedPeopleName":giftedPeopleName,"couponMoney":couponMoney};
    	 forms.uc=uc;
    	 
    	 $.ajax({
   		  url:"user/addUser",
   		  type:"post",
   		  data: JSON.stringify(forms),
             contentType:"application/json;charset=UTF-8", 
             dataType:"json",
             success: function(data){    
           	  if(data.code==200){
           		  layer.closeAll();
           		  $('#demo-table').bootstrapTable('refreshOptions',queryParams());
           	  }else{
           		  layer.msg(data.msg);
           	  }
             }
   	  });
    }
    
function inittable1(id,queryParams,columns,url){
	$('#'+id+'').bootstrapTable({
    	method:'GET',
        dataType:'json',
        contentType: "application/x-www-form-urlencoded",
        cache: false,
        striped: true,    
        sortOrder:"desc",
        //是否显示行间隔色
        sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
        url:url,
        height: $(window).height() - 110,
        width:$(window).width(),
        /* showColumns:true, */
        pagination:true,
        queryParams : queryParams,
        minimumCountColumns:2, 
        pageNumber:1,                       //初始化加载第一页，默认第一页
              pageSize:10,                       //每页的记录行数（*）
              pageList: [5,10,15,25,50,100],        //可供选择的每页的行数（*）
              uniqueId: "id",                     //每一行的唯一标识，一般为主键列
        showExport: true,                    
        exportDataType: 'all',
        responseHandler: responseHandler,
        columns: columns,
        onSort:function(name, order){
        	$('#sortName').val(name);
        }
    });
}

function exportTable(){
	var telephone = $('#telephone').val();
    var startTime= $('#startTime').val();
   var  endTime=$('#endTime').val();
   var isOnline=$('#isOnline').val();
   var isDeleted= $('#isDeleted').val();
    var sex =$('#sex').val();
	window.location.href="user/exportUserList?telephone="+telephone+"&startTime="+startTime+"&endTime="+endTime+"&isOnline="+isOnline+"&isDeleted="+isDeleted+"&sex="+sex
}
    //初始化城市
    function initCity() {
        $.getJSON({
            url: "user/getCity",
            data: {},
            success: function (data) {
                if (data.code == 200) {
                    $('#city').append("<option value=''>Please select a</option>");
                    for (var i in data.data) {
                        $('#city').append("<option value='" + data.data[i].id + "'>" + data.data[i].cityName + "</option>");
                    }
                } else {
                    layer.msg(data.msg);
                }
            }
        });
    }

    var columns = [{field: '', title: 'choose', checkbox: true},
    	{
        field: 'id',
        title: 'Operation(操作)',
        align: 'center',
        valign: 'middle',
        formatter: function (value, row, index) {
            var str = '<a class="btn btn-info" style="margin-left:5px" href="user/info?id='+row.id+'">Details</a>'
                +'<button ';
            str += '<a class="btn btn-info" style="margin-left:5px;background-color: darkcyan;border-color: #76d8cf;" href="javascript:void();" onclick="del('+row.id+')">Delete</a>'
            +'<button ';
            if(row.isDeleted == 0){
                str += 'class="btn btn-danger" style="margin-left:5px" onclick="changeStatus('+row.id+',1,this)">Disable</button>';
            }else{
                str += 'class="btn btn-info" style="margin-left:5px" onclick="changeStatus('+row.id+',0,this)">Enable</button>';
            }
            return str;
        }
    },
    {
        field: 'push',
        title: 'push(发送短信)',
        align: 'center',
        valign: 'middle',
        formatter: function (value, row, index) {
        	return '<a class="btn btn-info" style="margin-left:5px;background-color: darkcyan;border-color: #76d8cf;" href="javascript:void();" onclick="send(\''+row.telephone+'\')">Send</a> ';
        }
    },
    {
        field: 'giving',
        title: 'Allocate Voucher(赠送优惠劵)',
        align: 'center',
        valign: 'middle',
        formatter: function (value, row, index) {
        	return '<a class="btn btn-info" style="margin-left:5px;background-color: darkcyan;border-color: #76d8cf;" href="javascript:void()"  onclick="giving('+row.id+',\''+row.telephone+'\')">Allocate</a> ';
        }
    },{
            field: 'picture',
            title: 'Head portrait(头像)',
            align: 'center',
            valign: 'middle',
            formatter: function (value, row, index) {
                return value == null ? "" : "<img src='" + value + "' style='width:60px;height:60px'/>";
            }
        },
        {
            field: 'firstName',
            title: 'Name(名称)',
            align: 'center',
            valign: 'middle'
        },
        {
            field: 'telephone',
            title: 'Mobile(电话)',
            align: 'center',
            valign: 'middle',
            formatter: function (value, row, index) {
            	return "04"+value;
            }
        },
        {
            field: 'sex',
            title: 'Gender(性别)',
            align: 'center',
            valign: 'middle',
            formatter: function (value, row, index) {
                if (value == 0) {
                    return "male";
                } else if (value == 1) {
                    return "female";
                } else {
                    return "other";
                }
            }
        },
        {
            field: 'email',
            title: 'Email(邮箱)',
            align: 'center',
            valign: 'middle'
        },
        {
            field: 'address',
            title: 'Address(地址)',
            align: 'center',
            valign: 'middle'
        },
        {
            field: 'postcode',
            title: 'Postcode(邮编)',
            align: 'center',
            valign: 'middle'
        },
        {
            field: 'mileage',
            title: 'Mileage(里程)',
            align: 'center',
            valign: 'middle'
        },
        {
            field: 'consumetotal',
            title: 'Total Spending(消费金额)',
            align: 'center',
            valign: 'middle'
        },
        {
            field: 'invitenum',
            title: 'Successful Invitations(邀请数)',
            align: 'center',
            valign: 'middle'
        },
        {
            field: 'isOnline',
            title: 'Is it online(是否在线)',
            align: 'center',
            valign: 'middle',
            formatter: function (value, row, index) {
                return value != null && value == 1 ? "online" : "offline";
            }
        },
        {
            field: 'createTime',
            title: 'Registration time(注册时间)',
            align: 'center',
            valign: 'middle',
            formatter: timeStamp2String,
            sortable:true
        },
        {
            field: 'loginTime',
            title: 'Last Logon(上次登录时间)',
            align: 'center',
            valign: 'middle',
            formatter: timeStamp2String,
            sortable:true
        },
        {
            field: 'isDeleted',
            title: 'Status(是否禁用)',
            align: 'center',
            valign: 'middle',
            formatter: function (value, row, index) {
                return value != null && value == 1 ? "Disabled" : "Enabled";
            }
        }
        
    ];
    //赠送优惠劵
    function giving(id,telephone){
    	layer.open({
			  type: 1,
			  title: "Send Message",
			  skin: 'layui-layer-rim', //加上边框
			  area: ['420px', '360px'], //宽高
			  content: ' <form id="giving"><table>'+
  '  <tr class="padtr"><td class="pad">Voucher Name(优惠劵名称):</td> '+
  '<td><input type="text" name="couponName" id="couponName"/><input type="hidden" name="telephone" value="'+telephone+'"/>'
  +'<input type="hidden" name="type" value="1"/><input type="hidden" name="giftedPeopleName" value="${user.name}"/><input type="hidden" name="uId" value="'+id+'"/></td></tr>'+
  
  '  <tr class="padtr"><td class="pad">Voucher Amount(优惠劵金额):</td> '+
  '<td><input type="number" name="couponMoney" id="couponMoney"  oninput="regca(\'couponMoney\')"/></td></tr>'+
  '  <tr class="padtr"><td class="pad">Description(描述):</td> '+
  '<td><input type="text" name="remark" id="remark"/></td></tr>'+
  '<tr align="center" class="padtr" ><td colspan="5" style="padding-top:10px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
   ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
   ' <button type="button" onclick="cacel()" class="btn btn-info btn1">&nbsp;&nbsp;Cancel&nbsp;&nbsp;</button>'+
   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
   '<button type="button" onclick="givingContent()" class="btn btn-info btn1">&nbsp;&nbsp;Confirm&nbsp;&nbsp;</button></td></tr></table></form>'
			});
    }
    function givingContent(){
    	var forms= serialize('giving');
 	   if(forms.couponName==null||forms.couponName==""){
 		   layer.msg("Coupon Name cannot be empty");
    		   return;
 	   }
 	  if(forms.couponMoney==null||forms.couponMoney==""){
		   layer.msg("Coupon amount cannot be empty");
   		   return;
	   }
 	 layer.load(1, { shade: [0.1,'#fff'] //0.1透明度的白色背景
 		});
 	 $.ajax({
  		  url:"user/sendACoupon",
  		  type:"post",
  		  data: JSON.stringify(forms),
            contentType:"application/json;charset=UTF-8", 
            dataType:"json",
            success: function(data){    
          	  if(data.code==200){
          		  layer.closeAll();
          		  $('#demo-table').bootstrapTable('refreshOptions',queryParams());
          	  }else{
          		  layer.msg(data.msg);
          	  }
            }
  	  });
 	  
    }
    function send(telephone){
    	layer.open({
			  type: 1,
			  title: "Send Message",
			  skin: 'layui-layer-rim', //加上边框
			  area: ['420px', '360px'], //宽高
			  content: ' <form  id="sends"><table>'+
    '  <tr class="padtr"><td class="pad">Content(短信内容):</td> '+
    '<input name="phone" type="hidden" value="'+telephone+'"/><input name="platform" type="hidden" value="8"/>'+
    '<td><textarea rows="5" cols="20" name="vcode"></textarea></td></tr>'+
    '<tr align="center" class="padtr" ><td colspan="5" style="padding-top:10px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
     ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
     ' <button type="button" onclick="cacel()" class="btn btn-info btn1">&nbsp;&nbsp;Cancel&nbsp;&nbsp;</button>'+
     '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
     '<button type="button" onclick="sendContent()" class="btn btn-info btn1">&nbsp;&nbsp;Send&nbsp;&nbsp;</button></td></tr></table></form>'
			});
    }
    function regca(id){
    	 var text=$('#'+id+'').val();
    	if(parseInt(text)<=0){
    		 $('#'+id+'').css("border-color","#FF0000")
    	}else{
    		$('#'+id+'').css("border-color","#ccc")
    	}
    }
   
   function sendContent(){
	   var forms= serialize('sends');
	   if(forms.vcode==null||forms.vcode==""){
		   layer.msg("Content cannot be empty");
   		   return;
	   }
	   $.ajax({
	   		  url:"user/sendSMS",
	   		  type:"post",
	   		  data: JSON.stringify(forms),
	             contentType:"application/json;charset=UTF-8", 
	             dataType:"json",
	             success: function(data){    
	           	  if(data.code==200){
	           		  layer.closeAll();
	           		  $('#demo-table').bootstrapTable('refreshOptions',queryParams());
	           	  }else{
	           		  layer.msg(data.msg);
	           	  }
	             }
	   	  });
	   
   }
function del(id){
	var  flag =  confirm("Are you sure you want to delete?");				
	  if(flag){
			 $.ajax({
		            type: "get",
		            url: "user/deleteUser",
		            dataType:"json",
		            data:{"id":id},
		            success: function(data){    
		           	  console.log(data)
		          	  if(data.code==200){	 
		          		doQuery1('demo-table',queryParams1());
			        	 }else{
			        		  layer.msg(data.msg); 
			        	 }
		       }
		        }); 
	  }
}
    function queryParams(params) {
        var param = {
            telephone: $('#telephone').val(),
            startTime: $('#startTime').val(),
            endTime: $('#endTime').val(),
            isOnline: $('#isOnline').val(),
            isDeleted: $('#isDeleted').val(),
            sex:$('#sex').val(),
            order:this.sortOrder,
              sortname:$('#sortName').val(),  
            pageNo: this.pageNumber,
            pageSize: this.pageSize
        }
        return param;
    }

    function queryParams1() {
        var param = {
            telephone: $('#telephone').val(),
            startTime: $('#startTime').val(),
            endTime: $('#endTime').val(),
            isOnline: $('#isOnline').val(),
            isDeleted: $('#isDeleted').val(),
            sex:$('#sex').val(),
            pageNo: 1,
            pageSize: this.pageSize
        }
        return param;
    }

    function changeStatus(id,isDeleted,current) {
        $.post(
            "user/update",
            {id:id,isDeleted:isDeleted},
            function (json) {
                if(json.code == 200){
                    M.dialog2 = jqueryAlert({
                        'title': 'Notification(提示)',
                        'content': '<p>Successful</p>',
                        'width': "320",
                        'modal': true,
                        'buttons': {
                            'OK': function () {
                                M.dialog2.close();
                            }
                        }
                    });
                    if(isDeleted == 0){
                        $(current).attr("class","btn btn-danger");
                        $(current).attr("onclick","changeStatus("+id+",1,this)");
                        $(current).parent().prev().text("Enable");
                        $(current).text("Disable");
                    }else{
                        $(current).attr("class","btn btn-info");
                        $(current).attr("onclick","changeStatus("+id+",0,this)");
                        $(current).parent().prev().text("Disable");
                        $(current).text("Enable");
                    }
                }else{
                    M.dialog2 = jqueryAlert({
                        'title': 'Notification(提示)',
                        'content': '<p>Not Successful</p>',
                        'width': "320",
                        'modal': true,
                        'buttons': {
                            'OK': function () {
                                M.dialog2.close();
                            }
                        }
                    });
                }
                if (M.dialog2) {
                    return M.dialog2.show();
                }
            }
        )
    }
</script>
</html>


